<?php

	
	include "../config.php";
	include "../thu_vien/xl_user.php";
	include "../thu_vien/convert_vi_to_en.php";

	$dt_xl_user = new xl_user;
	$sl_user = $dt_xl_user->so_luong();
	echo $sl_user;
	$all_user = $dt_xl_user->danh_sach('0',$sl_user);
	
	
	foreach ($all_user as $user){
		$username = $user['username'];
		if ($username == ''){
			$username = convert_vi_to_en($user['name']);
		}
		$dt_xl_user->cap_nhat_nguoi_dung($username,'123456',$user['uid']);
	}
	
	/*$nguoi_dung = $dt_xl_user->kiem_tra_dang_nhap($_POST['ten_dang_nhap'], $_POST['mat_khau']);
	#kiêm tra
	if($nguoi_dung == NULL)
	{
		$_SESSION['msg'] = 'Lỗi ! tên đăng nhập hoặc mật khẩu không đúng.';
		$_SESSION['type_msg'] = 'error';
		header('Location: '.$_SERVER['HTTP_REFERER']);
		exit;
	}
	#Login thanh công
	$_SESSION[HASH.'_LOGIN'] = 'OK';
	$_SESSION['USERNAME'] = $nguoi_dung['ho_ten'];
	$_SESSION['MA_NGUOI_DUNG'] = $nguoi_dung['ma'];
	$_SESSION['NGON_NGU'] = $_POST['ngon_ngu'];
	
	if (isset($_POST['remember'])){
		setcookie('USERNAME', $_POST['ten_dang_nhap'], time() + 14*24*60*60 ,'/');
		setcookie('PASSWORD', base64_encode($_POST['mat_khau']), time() + 14*24*60*60, '/');//Luu trong 2 tuan		
	}
	
	if ($_COOKIE['REFERER'] == '') {
		header('Location: ../trang_chu/index.php');
	} else {
		
		header('Location: '.urldecode($_COOKIE['REFERER']));
	}*/
	
?>